using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class BashListener {

	private List<System.Action<BashEvent>> listeners;
	
	// Singleton pattern.
	private static BashListener instance;
	public static BashListener inst() {
		if (instance == null) instance = new BashListener();
		return instance;
	}
	
	// Constructor.
	private BashListener() {
		listeners = new List<System.Action<BashEvent>>();
	}
	
	// Add a listener on a specific channel.
	public void add(System.Action<BashEvent> listener) {
		listeners.Add(listener);
	}
	
	// Notify listeners on a specific channel.
	public void notify(BashEvent bashEvent) {
		foreach (System.Action<BashEvent> listener in listeners) {
			listener(bashEvent);
		}
	}
}
